package com.oocl.hgl.crm.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class AppHelper {

	public static void menu() {
		System.out.println( "======================================================" );
//		System.out.println();

		printHelpDoc("L");
		printHelpDoc("A");
		printHelpDoc("D");
		printHelpDoc("U");
		printHelpDoc("O");
		printHelpDoc("H");
		printHelpDoc("Q");
		
//		System.out.println();
		System.out.println( "======================================================" );
	}

	public static void printHelpDoc(String str) {
		switch (str) {
		case "L":
			System.out.println( " 01、查看" );
			System.out.println( "  01、查看所有：输入 ‘L’,回车" );
			System.out.println( "  02、根据姓名查看：输入 ‘L name：xxx’,回车" );
			break;
		case "A":
			System.out.println( " 02、添加" );
			System.out.println( "     输入‘A name:xxx[,gender:xxx][,birthday:xxx][,address:xxx][,phone:xxx]’（其中 [] 为可选部分）,回车" );
			break;
		case "D":
			System.out.println( " 03、删除" );
			System.out.println( "     输入‘D id,回车" );
			break;
		case "U":
			System.out.println( " 04、修改" );
			System.out.println( "     输入‘U id name:xxx[,gender:xxx][,birthday:xxx][,address:xxx][,phone:xxx]’（其中 [] 为可选部分）,回车" );
			break;
		case "O":
			System.out.println( " 05、排序" );
			System.out.println( "  01、根据 id 排序,输入‘O id’,回车" );
			System.out.println( "  01、根据姓名排序,输入‘O name’,回车" );
			break;
		case "H":
			System.out.println( " 06、帮助" );
			System.out.println( "  01、查看全部帮助文档" );
			System.out.println( "   输入‘H’，回车" );
			System.out.println( "  02、查看制定帮助文档" );
			System.out.println( "   输入‘H X’（其中 X 可以为 L、A、D、U、O），回车" );
			break;
		case "Q":
			System.out.println( " 07、退出" );
			System.out.println( "   输入‘Q’，回车" );
			break;
		default:
			help();
			break;
		}
	}


	public static void help() {
		System.out.println(" 输入错误，输入‘H’，回车，查看帮助文档");
	}

	public static long getBirthday(String dateStr,String dateFormat){
		try {
			return new SimpleDateFormat(dateFormat).parse(dateStr).getTime();
		} catch (ParseException e) {
//			e.printStackTrace();
			System.out.println( "String to Date,class cast fail,when :" );
			System.out.println( "dateStr :" + dateStr);
			System.out.println( "dateFormat :" + dateFormat);
		}
		return 0;
	}
	public static String getBirthday(long l,String dateFormat){
		return new SimpleDateFormat(dateFormat).format(new Date(l));
	}


}
